<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/19
 * Time: 15:45
 */

namespace app\company\controller;


use app\common\model\SysNotice;
use app\common\model\SysNoticeLog;
use think\Exception;

class Notice extends Admin
{

    /**
     * 配置信息列表
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getList(){
        $page = input('page',1);
        $limit = input('limit',20);
        $search_word = input('search_word', '', 'trim');
        $param = ['state'=>1,'user_type'=>['in',[0,2]]];
        if($search_word){ //基础配置
            $param['notice_title|content'] = ['like','%'.$search_word.'%'];
        }
        $model = new SysNotice();
        $count = $model->where($param)->count();
        if($page > ceil($count/$limit)){
            $page = ceil($count/$limit);
        }
        $list = $model->where($param)->page($page,$limit)->order('id desc')->select();
        return json_tab_msg($count, $page, $list);
    }
}